#include "GameData.h"
#include "iostream"


int main()
{
	GameData data;
	/*
	data.SetValue(419,L"player.1.hp");
	data.SetValue(float(213.5),L"player.2.hp");
	data.SetValue(46545452,L"player.2.name");
	data.SetValue(L"1234",L"player.3.hp");
	GameData* test=data.getValue(L"player.1.hp");
	int a=test->toInt();
	cout<<"player1.hp is:";
	cout<<a;
	cout<<endl;
	cout<<"player2.hp is:";
	test=data.getValue(L"player.2.hp");

	cout<<test->toFloat();
	cout<<endl;
	test=data.getValue(L"player.2.name");
	wstring tmp=test->toString();
	cout<<"player.2.name is:";
	wprintf(tmp.c_str());
	cout<<endl;
	test=data.getValue(L"player.3.hp");
	 a=test->toInt();
	cout<<"player3.hp is: "<<a;
	
	*/
	
	int i1=100;
	int i2=40;
	float f1=12.1;
	float f2=8.56;
	wstring s1(L"aaabbb");
	wstring s2(L"bbc");

	data.SetValue(i1,L"player.1.hp");
	data.SetValue(i2,L"player.2.hp");
	data.SetValue(f1,L"player.1.mp");
	data.SetValue(f2,L"player.2.mp");
	data.SetValue(s1,L"player.1.ap");
	data.SetValue(s2,L"player.2.ap");
	GameData *mp=data.getValue(L"player.1.mp");
	GameData *hp=data.getValue(L"player.2.mp");
	GameData ap;
//	data.SetValue(*(wstring*)s,s1);
//	cout<<ap.getValue(L"")->toInt()<<endl;
//	cout<<(*hp).toInt()<<endl;
//	cout<<(*hp).toFloat()<<endl;
//	wstring s3(s1);
//	wprintf((s3).c_str());
/*
	
	for(n=0;n<50000;n++)
	{
		data.SetValue(i1,L"player.1.hp");
		i1++;
		cout<<"player.1.hp is:"<<hp->getValue(L"")->toInt()<<endl;
	}

*/

	wstring v1(L"20+{#source}.hp={#source}.hp-1+{#source}");
	wstring v2(L"player1");
	int begin=v1.find_first_of('{');
	int end=v1.find_first_of('}');
	for(;begin>=0&&end>=0;)
	{
	wstring pad=(v1.substr(begin+2,end-2));
	v1.replace(begin,end-begin+1,v2);
	begin=v1.find_first_of('{');
	end=v1.find_first_of('}');
	}




//	GameData *test=data.getValue(L"player.1.hp");
//	GameData *p=data.getValue(L"player.2.hp");
//	GameData q;
//	q=*test+*p;
	//cout<<((*test+*p).getValue(L""))->toFloat();	
	//test=p;
	
	//cout<<test->getValue(L"")->toFloat()<<endl;
	wprintf(v1.c_str());
	getchar();
	return 0;
}